<?php
// +----------------------------------------------------------------------
// | Description: 1
// +----------------------------------------------------------------------
// | Author: orchief
// +----------------------------------------------------------------------
// | Date: 2018-01-24 17:00:12
// +----------------------------------------------------------------------

namespace app\client\model;

use app\common\model\CommonClient;

class Cart extends CommonClient
{
    protected $fuzzyConditions = null;
    protected $clearConditions = ['UserId'];
    protected $returnFields = '
        shop_cart.Id,
        shop_cart.ProductId,
        shop_cart.ProductName,
        shop_cart.SkuId,
        shop_cart.Quantity,
        shop_cart.CreateAt
    ';
    protected $rangeConditions = null;
    protected $union_fuzzyConditions = null;
    protected $foreignConditions = null;
    protected $name = 'shop_cart';

        /**
     * [createData 新建]
     * @linchuangbin
     * @DateTime  2017-02-10T21:19:06+0800
     * @param     array                    $param [description]
     * @return    [array]                         [description]
     */
    public function createData($param)
    {
        // 验证
        $validate = validate($this->name);
        if (!$validate->check($param)) {
            $this->error = $validate->getError();
            return false;
        }
        try {
            $this->data($param)->allowField(true)->save();
            return true;
        } catch (\Exception $e) {

            $this->error = '已添加';
            return false;
        }
    }
}
